<template>
  <div>
    <div class="pltxt" v-if="setName!=undefined">{{setName}} <span v-if="setUntil!=undefined">({{setUntil}})</span></div>
    <van-form @submit="onSubmit">
      <van-field
        v-model="setValue_parent"
        type="digit" 
        show-error 
        clearable
        name="validator"
        :rules="[{ validator,message:  `${$t('Range')}：${setMin}-${setMax},${$t('Multiple50')}` }]"
        @clear="$emit('update:setValue','')"
      >
      <template #button>
        <van-button size="small" round class="setbtn">{{$t('Save')}}</van-button>
      </template>
      </van-field>
    </van-form>
  </div>
</template>

<script>

export default {
  props:['setName','setUntil','setValue','setMin','setMax','valName','subOption'],
  data(){
    return {
      setValue_parent:this.setValue
    }
  },
  watch: {
    setValue:{
      handler(nv,ov){
        this.setValue_parent = nv
      }
    }
  },
  methods: {
    validator(val){
      return this.comm.fixedfifthNum(val,this.setMin,this.setMax);
    },
    onSubmit(){
      let formData={};
      formData[this.valName]=this.setValue_parent;
      this.comm.setData(this.subOption,formData);
    }
  }
}
</script>

<style scoped lang="less">

</style>